package net.sky.oa.model;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

/**
 * 发帖表
 * SendPost. @author ...
 */
@Entity
@Table(name = "SENDPOST")//发帖表
public class SendPost implements java.io.Serializable {

	private static final long serialVersionUID = 5673991033245515351L;
	
	// Fields

	protected Long id;
	private Integer type;        //类型：贴图专区、原创地带..
	private String title;       //帖子标题
	private String content;     //帖子内容
	private Date createtime;    //帖子发表时间
	private Integer peoplecount;//浏览次数
	private Integer isreply;      //回复帖子数
	private SysEmployee user;     //发表人
	private String lastreply;  //最后发表人及时间
	private String dept;  //发表部门

	// Constructors

	/** default constructor */
	public SendPost() {
	}
	
	public SendPost(Long id,Integer type,String title,Integer peoplecount,
			Integer isreply,SysEmployee user,String lastreply){
		this.id=id;
		this.type=type;
		this.title=title;
		this.peoplecount=peoplecount;
		this.isreply=isreply;
		this.user=user;
		this.lastreply=lastreply;
	}
	
	public SendPost(Long id,String title){
		this.id=id;
		this.title=title;
	}
	
	/**
	 * @param id
	 * @param title
	 * @param createtime
	 * @param user
	 */
	public SendPost(Long id, String title, Date createtime, SysEmployee user) {
		super();
		this.id = id;
		this.title = title;
		this.createtime = createtime;
		this.user = user;
	}

	@Id
    @Column(name = "ID", unique = true, nullable = false)
	@SequenceGenerator(name="SQ_SENDPOST_ID",sequenceName="SQ_SENDPOST_ID",allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SQ_SENDPOST_ID")
	public Long getId() {
        return id;
    }

    public void setId(Long id){
    	this.id = id;
    }

	/** minimal constructor */
	public SendPost(Long id) {
		this.id = id;
	}
	
	@Column(name = "TYPE", precision = 2, scale = 0)
	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Column(name = "TITLE", length = 100)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
    
	@Lob
    @Basic(fetch = FetchType.EAGER)
    @Column(name = "CONTENT", columnDefinition = "CLOB", nullable = true)
    @Type(type ="org.springframework.orm.hibernate3.support.ClobStringType")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATETIME")
	public Date getCreatetime() {
		return this.createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}



	@Column(name = "PEOPLECOUNT", precision = 5, scale = 0)
	public Integer getPeoplecount() {
		return this.peoplecount;
	}

	public void setPeoplecount(Integer peoplecount) {
		this.peoplecount = peoplecount;
	}
    
	@Column(name = "ISREPLY", precision = 5, scale = 0)
	public Integer getIsreply() {
		return isreply;
	}

	public void setIsreply(Integer isreply) {
		this.isreply = isreply;
	}
    
	@Column(name = "LASTREPLY", precision = 5, scale = 0)
	public String getLastreply() {
		return lastreply;
	}

	public void setLastreply(String lastreply) {
		this.lastreply = lastreply;
	}
	@Column(name = "DEPT",length = 100)
	public String getDept() {
		return dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "USER_ID")
	public SysEmployee getUser() {
		return this.user;
	}

	public void setUser(SysEmployee user) {
		this.user = user;
	}

}
